﻿using ApiConceptsFramework.Concepts.Properties;
using ApiConceptsFramework.Contract;
using FluentAssertions;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test.ApiConceptsFramework.Concepts.Properties
{
	[TestFixture]
	public class NumberOfClassesInPackageTests
	{
		[Test]
		public void Complexity_is_correctly_calculated()
		{
			//Arrange
			var measurableProperty = new NumberOfClassesInPackage();
			var type = typeof (NumberOfClassesInPackage);
			const float expectedResult = (7 - 10)*NumberOfClassesInPackage.NumberOfClassesToComplexityFactor;

			//Act
			var result = measurableProperty.CalculateComplexity(new MeasurableTarget{Type = type}, IDE.VisualStudioOrSimilar);

			//Assert
			result.Should().Be(expectedResult, "because there are 7 classes in the package ApiConceptsFramework.Concepts.Properties");
		}

		[Test]
		public void No_suggestion_is_made_for_small_number_of_classes_in_package()
		{
			//Arrange
			var measurableProperty = new NumberOfClassesInPackage();
			var type = typeof(NumberOfClassesInPackage);

			//Act
			var result = measurableProperty.GetSuggestions(new MeasurableTarget { Type = type }, IDE.VisualStudioOrSimilar);

			//Assert
			result.Should().BeEmpty();
		}

		[Test]
		public void Suggestion_is_made_for_large_number_of_classes_in_package()
		{
			//Arrange
			var measurableProperty = new NumberOfClassesInPackage();
			var type = typeof(string);

			//Act
			var result = measurableProperty.GetSuggestions(new MeasurableTarget { Type = type }, IDE.VisualStudioOrSimilar).ToList();

			//Assert
			result.Should().HaveCount(1);
			Console.WriteLine(result.First());
		}
	}
}
